import logging
import logging.config
import ConfigParser
import os

BASEDIR = os.path.split(os.path.realpath(__file__))[0]
#DATABASEURI = 'mysql://flask:123456@localhost/flask'
DATABASEURI = 'mysql://mondo:123456@mysql_server/mondo'
PG_DATABASEURI = 'postgresql+pygresql://mondo:1111@127.0.0.1:5432/mdo'
#PG_DATABASEURI = 'postgresql+pygresql://pipe:pipe123@132.121.130.18:5433/mondo'
# DATABASEURI = 'mysql://mondo:du#1dx@op2.ecld.com/mondo'

#LOG_CONF_FILE = os.path.join(BASEDIR, '../', 'conf', 'log.conf')
LOG_FILE_PATH = os.path.join('/', 'log', 'mondo-server.log')
LOG_ROTATION = True
LOG_ROTATION_COUNT = 5

CLEANER_INTERVAL = 900

from logging import FileHandler
from logging.handlers import TimedRotatingFileHandler as Rotater

logger = logging.getLogger('server')
logger.setLevel(logging.DEBUG)

formatter = logging.Formatter("%(asctime)s :%(threadName)s: %(message)s",
                              "%a %b %d %H:%M:%S %Y")
if LOG_ROTATION:  # if we want to rotate logs
    handler = Rotater(LOG_FILE_PATH,
                      when='midnight',
                      backupCount=LOG_ROTATION_COUNT)
else:  # let someone else, e.g. logrotate, rotate the logs
    handler = FileHandler(LOG_FILE_PATH)

handler.setFormatter(formatter)
logger.addHandler(handler)

GOLIA_URLS = ['http://d0n0.ecld.com:8321/datapoints',
              'http://d0n0.ecld.com:8322/datapoints',
              'http://d0n1.ecld.com:8210/datapoints',
              'http://d0n1.ecld.com:8211/datapoints',
              'http://d0n1.ecld.com:8212/datapoints',
              'http://d0n2.ecld.com:8327/datapoints',
              'http://d0n2.ecld.com:8328/datapoints',
              'http://d0n4.ecld.com:8323/datapoints',
              'http://d0n4.ecld.com:8324/datapoints',
              'http://d0n4.ecld.com:8329/datapoints']


def getlogger():
    return logger
